<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;

/**
 * 配置
 * Class System
 * @package app\admin\controller
 */
class StoreKnow extends AdminBase
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 配置
     */
    public function index()
    {
        $store_config = Db::name('store_know')->field('value')->where('name', 'store_config')->find();
        $store_config = unserialize($store_config['value']);

        return $this->fetch('store_config', ['store_config' => $store_config]);
    }

    /**
     * 更新配置
     */
    public function updateConfig()
    {
        if ($this->request->isPost()) {
            $store_config                = $this->request->post('store_config/a');
            $data['value']              = serialize($store_config);
            if (Db::name('store_know')->where('name', 'store_config')->update($data) !== false) {
                $this->success('提交成功');
            } else {
                $this->error('提交失败');
            }
        }
    }

}